/**
 * Created by IntelliJ IDEA.
 * User: Taras_Brzezinsky
 * Date: 8/29/11
 * Time: 6:02 PM
 * To change this template use File | Settings | File Templates.
 */

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.*;

public class TaskB extends Thread {
    public TaskB() {
        this.input = new BufferedReader(new InputStreamReader(System.in));
        this.output = new PrintWriter(System.out);
        this.setPriority(Thread.MAX_PRIORITY);
    }
    static final private void go(long current, long max) {
        if (current > max) {
            return;
        } else {
            lucky[SIZE++] = (int)current;
            go(current * 10 + 4, max);
            go(current * 10 + 7, max);
        }
    }

    private static final boolean liesIn(int []ends, int where) {
        return where >= ends[0] && where <= ends[1];
    }

    private final void solve() throws Throwable {
        int [][]ends  = new int[2][2];
        ends[0][0] = nextInt();
        ends[0][1] = nextInt();
        ends[1][0] = nextInt();
        ends[1][1] = nextInt();
        int k = nextInt();
        long total = (long)(ends[1][1] - ends[1][0] + 1) * (ends[0][1] - ends[0][0] + 1);
        long satisfied = 0;
        for (int i = 1; i + k < SIZE; ++i) {
            for (int where = 0; where < 2; ++where) {
                long first = Math.max(0, Math.min(ends[where][1], lucky[i]) -
                        Math.max(ends[where][0], lucky[i - 1] + 1) + 1);
                long second = Math.max(0, Math.min(ends[where ^ 1][1], lucky[i + k] - 1) -
                        Math.max(ends[where ^ 1][0], lucky[i + k - 1]) + 1);
                satisfied += first * second;
            }
            if (k == 1 && liesIn(ends[0], lucky[i]) && liesIn(ends[1], lucky[i])) {
                --satisfied;
            }
        }
        double result = satisfied;
        output.printf("%.15f", result / total);
    }

    public final void run() {
        try {
            solve();
        } catch (Throwable e) {
            System.err.println(e.getMessage());
            e.printStackTrace();
            System.exit(666);
        } finally {
            output.flush();
            output.close();
        }
    }

    public static void main(String[] args) {
        new TaskB().start();
    }

    private int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    private long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    private double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    private String nextToken() throws IOException {
        while (tokens == null || !tokens.hasMoreTokens()) {
            tokens = new StringTokenizer(input.readLine());
        }
        return tokens.nextToken();
    }
    static int SIZE = 0;
    static int []lucky = new int[1024];
    static {
        lucky[SIZE++] = Integer.MAX_VALUE / 2;
        go(0, (long)1e9);
        Arrays.sort(lucky);
    }
    Set<Integer> numbers = new TreeSet<Integer>();
    private BufferedReader input;
    private PrintWriter output;
    private StringTokenizer tokens = null;
}